/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						script_player_boolean_expression.h

	$Header: /heroes4/script_player_boolean_expression.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_PLAYER_BOOLEAN_EXPRESSION_H_INCLUDED )
#define SCRIPT_PLAYER_BOOLEAN_EXPRESSION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>

#include "script_expression_type.h"
#include "script_target_type.h"
#include "script_targeted_expression.h"

enum t_player_color;
enum t_town_type;

class t_player;

// --------------------------------------------------------------------------
// t_script_player_boolean_expression class
// --------------------------------------------------------------------------

class t_script_player_boolean_expression
	:	public t_script_targeted_boolean_expression< t_script_player_target >
{
public:
	virtual t_result	evaluate(t_expression_context_hero const& context) const;
	virtual t_result	evaluate(t_expression_context_town const& context) const;
	virtual t_result	evaluate(t_expression_context_object const& context) const;
	virtual t_result	evaluate(t_expression_context_army const& context) const;
	virtual t_result	evaluate(t_expression_context_global const& context) const;

protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const = 0;
};

// --------------------------------------------------------------------------
// t_script_player_is_computer class
// --------------------------------------------------------------------------

class t_script_player_is_computer : public t_script_player_boolean_expression
{
protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const;
};

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_player_is_computer, t_script_player_is_computer );

// --------------------------------------------------------------------------
// t_script_player_is_human class
// --------------------------------------------------------------------------

class t_script_player_is_human : public t_script_player_boolean_expression
{
protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const;
};

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_player_is_human, t_script_player_is_human );

// --------------------------------------------------------------------------
// t_script_player_is_eliminated class
// --------------------------------------------------------------------------

class t_script_player_is_eliminated : public t_script_player_boolean_expression
{
protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const;
};

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_player_is_eliminated, t_script_player_is_eliminated );

// --------------------------------------------------------------------------
// t_script_player_is_alignment class
// --------------------------------------------------------------------------

class t_script_player_is_alignment : public t_script_player_boolean_expression
{
public:
	// Types
	typedef t_town_type	t_alignment;

	// Constructor
	t_script_player_is_alignment();

	// Member functions
	t_alignment			get_alignment() const;
	virtual bool		read( std::streambuf& stream, int version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf& stream ) const;

protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const;

	// Data members
	t_alignment	m_alignment;
};

// --------------------------------------------------------------------------
// t_script_player_is_alignment inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_player_is_alignment::t_script_player_is_alignment()
	:	m_alignment( t_alignment( 0 ) )
{
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_player_is_alignment::t_alignment
t_script_player_is_alignment::get_alignment() const
{
	return m_alignment;
}

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_player_is_alignment, t_script_player_is_alignment );

// --------------------------------------------------------------------------
// t_script_player_is_color class
// --------------------------------------------------------------------------

class t_script_player_is_color : public t_script_player_boolean_expression
{
public:
	// Constructor
	t_script_player_is_color();

	// Member functions
	t_player_color		get_color() const;
	virtual bool		read( std::streambuf& stream, int version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf& stream ) const;


protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const;

	// Data members
	t_player_color	m_color;
};

// --------------------------------------------------------------------------
// t_script_player_is_color inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_player_is_color::t_script_player_is_color()
	:	m_color( t_player_color( 0 ) )
{
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_player_color t_script_player_is_color::get_color() const
{
	return m_color;
}

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_player_is_color, t_script_player_is_color );

// --------------------------------------------------------------------------
// t_script_player_owns_hero class
// --------------------------------------------------------------------------

class t_script_player_owns_hero : public t_script_player_boolean_expression
{
public:
	// Member functions
	std::string const &	get_hero_name() const;
	virtual bool		read( std::streambuf& stream, int version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf& stream ) const;


protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const;

	// Data members
	std::string	m_hero_name;
};

// --------------------------------------------------------------------------
// t_script_player_owns_hero inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline std::string const & t_script_player_owns_hero::get_hero_name() const
{
	return m_hero_name;
}

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_player_owns_hero, t_script_player_owns_hero );

// --------------------------------------------------------------------------
// t_script_player_owns_town class
// --------------------------------------------------------------------------

class t_script_player_owns_town : public t_script_player_boolean_expression
{
public:
	// Member functions
	std::string const &	get_town_name() const;
	virtual bool		read( std::streambuf& stream, int version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf& stream ) const;


protected:
	virtual t_result	do_evaluate(t_adventure_map const* map, t_player const* player) const;

	// Data members
	std::string	m_town_name;
};

// --------------------------------------------------------------------------
// t_script_player_owns_town inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline std::string const & t_script_player_owns_town::get_town_name() const
{
	return m_town_name;
}

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_player_owns_town, t_script_player_owns_town );

#endif // !defined( SCRIPT_PLAYER_BOOLEAN_EXPRESSION_H_INCLUDED )
